﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HCFramework.Master.Normal
{
    public partial class UsrAdminPanel : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.Visible = C.UserController.IsAdmin();

                LoadUserSetting();
            }
        }

        private void LoadUserSetting()
        {
            string state = M.Common.GetCookie("adminPanelVisible");
            if (state == "False") PanelAdmin.Visible = false;
            else PanelAdmin.Visible = true;
        }

        protected void LinkButtonShowHideAdmin_Click(object sender, EventArgs e)
        {
            PanelAdmin.Visible = !PanelAdmin.Visible;
            M.Common.SetCookie("adminPanelVisible", PanelAdmin.Visible.ToString(), DateTime.Now.AddMonths(1));
        }
    }
}